package com.lfy.aop;

import com.lfy.annotaion;
import com.lfy.test.testaop;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Aspect
@Component
public class BB {
    @Resource
    testaop aop;
    @Pointcut("@annotation(com.lfy.annotaion)")
    public void p(){

    }
    @Around("p()")
    public Object test(ProceedingJoinPoint point) throws Throwable {
        MethodSignature signature = (MethodSignature) point.getSignature();
        annotaion annotation = signature.getMethod().getAnnotation(annotaion.class);
        System.out.println(annotation.go());
        System.out.println(annotation.name());
        return aop.test(()->{return point.proceed();});
    }
}
